﻿using blackhouse.BlackApart.Business.Reservations;
using blackhouse.BlackApart.Web.Navigation;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using blackhouse.mojoPortalExtend;
using System.Globalization;

namespace blackhouse.StareKino.QuartzActions.ASyncMails {
    public partial class AdditionalInformation : System.Web.UI.UserControl {

        #region Properties

        protected string LinkToMainPage { get; set; }

        protected string LinkToGalleryPage { get; set; }

        public IWebReservation Reservation { get; set; }

        #endregion


        protected override void OnLoad(EventArgs e) {
            base.OnLoad(e);

            int siteId = 1;
            ReservationPage statusPage = ReservationPage.GetStatusPage(this.Reservation);
            if (this.Reservation.Client != null && !String.IsNullOrEmpty(this.Reservation.Client.PrefferLanguage)) {
                CultureInfo clientLanguage = CultureInfo.GetCultureInfo(this.Reservation.Client.PrefferLanguage);
                siteId = clientLanguage.GetSiteId();
            }
            statusPage.OverrideLanguageSiteId = siteId;
            this.lnkReservationStatus.NavigateUrl = NavigationProvider.Instance().GetUrl(statusPage);
            this.lnkReservationStatus.Text = "Status rezerwacji " + this.Reservation.ReservationNumber;

            PageProvider pageProvider = new PageProvider();
            this.LinkToMainPage = pageProvider.GetUrlToSite(siteId, "/");
            this.LinkToGalleryPage = pageProvider.GetUrlByFunctionality(siteId, "gallery");
            if (String.IsNullOrEmpty(this.LinkToGalleryPage))
                this.LinkToGalleryPage = this.LinkToMainPage;

            string host = Request.Url.GetLeftPart(UriPartial.Authority).ReplaceEx("http://", "");
            this.LinkToMainPage = host + this.LinkToMainPage;
            this.LinkToGalleryPage = host + this.LinkToGalleryPage;
        }

    }
}